﻿CREATE TRIGGER [dbo].[TR_MembershipRole_IUD]
   ON  [dbo].[MembershipRole]
   INSTEAD OF INSERT, UPDATE, DELETE
AS 
BEGIN
	SET NOCOUNT ON;
	DECLARE @RoleId INT;

	--IF EXISTS(SELECT * FROM INSERTED)
	--BEGIN
	--			INSERT [dbo].[MembershipRolePower]
	--		        ( PowerId ,
	--		          RoleId ,
	--		          GetFlag ,
	--		          AddFlag ,
	--		          EditFlag ,
	--		          DelFlag ,
	--		          ExecFlag
	--		        )
	--		SELECT	p.Id,
	--				i.Id,
	--				0,0,0,0,0
	--		FROM INSERTED i
	--		INNER JOIN dbo.MembershipPower p ON 
	--			NOT EXISTS(SELECT * FROM [dbo].[MembershipRolePower] rp WHERE rp.RoleId = i.Id AND rp.PowerId = p.Id )
	--END
	--ELSE IF EXISTS(SELECT * FROM DELETED)
	--BEGIN
	--  DELETE FROM [dbo].[MembershipRolePower] 
	--  WHERE RoleId IN (SELECT Id FROM DELETED)
	--END
END